import java.util.Scanner;

public class Test {
}



 class FibonacciSequence {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入需要生成的斐波那契数列的项数: ");
        int n = scanner.nextInt();
        scanner.close();

        if (n <= 0) {
            System.out.println("请输入一个正整数。");
            return;
        }

        System.out.println("斐波那契数列的前 " + n + " 项为:");
        for (int i = 0; i < n; i++) {
            System.out.print(fibonacci(i) + " ");
        }
    }

    // 递归方法计算斐波那契数列的第n项
    public static int fibonacci(int n) {
        if (n <= 1) {
            return n;
        } else {
            return fibonacci(n - 1) + fibonacci(n - 2);
        }
    }
}
